import os

from spider.database.config import *


def gen_models(path, _database=database):
    cmd_line = "sqlacodegen mysql+mysqlconnector://{user}:{password}@localhost/{database} > {path}/models.py".format(
        user=user,
        password=password,
        database=_database,
        path=path
    )
    os.system(cmd_line)


if __name__ == '__main__':
    # gen_models("D:\code\python\spider/test")
    base_path = os.getcwd()[:-9]
    gen_models(base_path)

